#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main()
{
	long long x;

	while (scanf("%lld", &x) != EOF)
	{
		long long x0 = x;
		int max = 1, n = 0;
		int a[100] = { 0 };
		if (x == 1)
		{
			printf("1 = 3^0\n");
		}
		else
		{
			for (int i = 0;max * 3 <= x;i++)
			{
				n++;
				max *= 3;

			}
			for (int n0 = n;n0 >= 0;n0--)
			{

				a[n0] = x0 / pow(3, n0);

				x0 -= a[n0] * pow(3, n0);
			}

			printf("%d =", x);

			for (int i = 0;i < n;i++)
			{
				if (a[i] == 0)
				{
					continue;
				}
				else if (a[i] == 1)
				{
					printf(" 3^%d +", i);
				}
				else
				{
					printf(" %d*3^%d +", a[i], i);
				}

			}

			if (a[n] == 1)
			{
				printf(" 3^%d\n", n);
			}
			else
			{
				printf(" %d*3^%d\n", a[n], n);
			}

		}
	}
	return 0;
}